<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>登录</title>
		<link rel="stylesheet" href="/ygcrafts/public/plugins/layui/css/layui.css" media="all" />
		<link rel="stylesheet" href="/ygcrafts/public/css/login.css" />

		<script type="text/javascript" src="/ygcrafts/public/js/jquery-3.1.1.js"></script>
		<script type="text/javascript" src="/ygcrafts/public/plugins/layui_new/layui.all.js"></script>

	</head>
	<body>

		<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" >

		  <div class="layadmin-user-login-main">
		    <div class="layadmin-user-login-box layadmin-user-login-header">
		      <h2>ygcrafts-Admin</h2>
		      <p>ygcrafts后台管理系统</p>
		    </div>


		    <form class="wen_form" >
		    <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
		      <!--  -->
		      <div class="layui-form-item">
		        <label class="layadmin-user-login-icon layui-icon layui-icon-username" for="LAY-user-login-username"></label>
		        <input name="username" id="wen-user-login-username"   placeholder="用户名" class="layui-input" type="text">
		      </div>
		      <!--  -->
		      <div class="layui-form-item">
		        <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label>
		        <input name="password" id="wen-user-login-password"  placeholder="密码" class="layui-input" type="password">
		      </div>
		      <!--  -->
		      <div class="layui-form-item">
		        <div class="layui-row">
		          <div class="layui-col-xs7">
		            <label class="layadmin-user-login-icon layui-icon layui-icon-vercode" for="LAY-user-login-vercode"></label>
		            <input name="vercode" id="wen-user-login-vercode"  placeholder="验证码" class="layui-input" type="text">
		          </div>
		          <div class="layui-col-xs5">
		            <div style="margin-left: 10px;">
		              <img src="/ygcrafts/admin.php/Login/verify" onclick="this.src='/ygcrafts/admin.php/Login/verify?'+Math.random()">
		            </div>
		          </div>
		        </div>
		      </div>
		      <!--  -->
		      <!-- <div class="layui-form-item" style="margin-bottom: 20px;"></div> -->
		      <div class="layui-form-item">
		        <a class="layui-btn"  onclick="login()" style="width:335px" id='hc'>登 入</a>
		      </div>
		      <div class="layui-trans layui-form-item layadmin-user-login-other">
		        <!-- <label>社交账号登入</label>
		        <a href="javascript:;"><i class="layui-icon layui-icon-login-qq"></i></a>
		        <a href="javascript:;"><i class="layui-icon layui-icon-login-wechat"></i></a>
		        <a href="javascript:;"><i class="layui-icon layui-icon-login-weibo"></i></a> -->
		        <!-- <a class="layadmin-user-jump-change layadmin-link " style="margin-top: 7px;" onclick="no_now()">注册帐号</a>
		        <a class="layadmin-user-jump-change layadmin-link wen_aa" style="margin-top: 7px;" onclick="no_now()">忘记密码？</a> -->
		      </div>
		    </div>
		  </div>
		  </form>

		  <div class="layui-trans layadmin-user-login-footer">
		    <p>© 2018 <a href="" target="_blank">ygcrafts.com</a></p>
		    <p>
		      <!-- <span><a href="" target="_blank">联系我们</a></span>
		      <span><a href="" target="_blank">加入我们</a></span> -->
		      <span><a href="" target="_blank">前往官网</a></span>
		    </p>
		  </div>

		</div>
	</body>
</html>

<script>
	function no_now(){
		layer.msg('功能尚未开通',{
	    	time:500             //时间
	    	,offset: '300px'     //位置
	    });
	}
	//提交
	function login(){
		//验证
		var username = $('#wen-user-login-username').val()
		var password = $('#wen-user-login-password').val()
		var vercode = $('#wen-user-login-vercode').val()
		// alert(username.length);
		if(username.length == 0){
			layer.msg('用户名不能为空',{
		    	time:500             //时间
		    	,offset: '300px'     //位置
		    });
		    $('#wen-user-login-username').css('border','1px solid #ff0000');
		    var timer = setTimeout(function () {
		          $('#wen-user-login-username').css('border','1px solid #e6e6e6');
		     },1000);
		    return false
		}
		if(password.length == 0){
			layer.msg('密码不能为空',{
		    	time:500             //时间
		    	,offset: '300px'     //位置
		    });
		    $('#wen-user-login-password').css('border','1px solid #ff0000');
		    var timer = setTimeout(function () {
		          $('#wen-user-login-password').css('border','1px solid #e6e6e6');
		    },1000);
		    return false
		}
		if(vercode.length != 4){
			layer.msg('请输入四位验证码',{
		    	time:500             //时间
		    	,offset: '300px'     //位置
		    });
		    $('#wen-user-login-vercode').css('border','1px solid #ff0000');
		    var timer = setTimeout(function () {
		          $('#wen-user-login-vercode').css('border','1px solid #e6e6e6');
		    },1000);
		    return false
		}
		// 提交
		var url = "/ygcrafts/admin.php/login/check";
		$.ajax({
		    type:"post",
		    url:url,
		    data:$(".wen_form").serialize(),  //序列化表单里面的所有参数
		    dataType:"json", //服务器返回类型
		    success:function(msg){
		    	// console.log(msg)
		    	// alert(msg.msg);
		        if(msg.status == 0){
		            layer.msg(msg.msg,{
				    	time:500             //时间
				    	,offset: '300px'     //位置
				    })
		        }else{
		        	layer.msg(msg.msg,{
				    	time:500             //时间
				    	,offset: '300px'     //位置
				    	,end:function () {
					        window.location.href='/ygcrafts/admin.php/index/index';
					     }                            //结束后的回调
				    })
		        	// window.location.href='/ygcrafts/admin.php/index/index';
		        	
		        }
		    }
		});
	}


	$(document).keydown(function(event){
	 if(event.keyCode==13){
	  $('#hc').click();
	 }
	});
</script>